let url_host = window.location.host;
var cnut = 1;
var music = document.getElementById("audio");

//   设置全屏 // 设置全屏
$('#alarm-fullscreen-toggler').on('click', function (e) {
    var element = document.documentElement; // 返回 html dom 中的root 节点 <html>
    if (!$('body').hasClass('full-screen')) {
        $('body').addClass('full-screen');
        $('#alarm-fullscreen-toggler').addClass('active');
        // 判断浏览器设备类型
        if (element.requestFullscreen) {
            element.requestFullscreen();
        } else if (element.mozRequestFullScreen) { // 兼容火狐
            element.mozRequestFullScreen();
        } else if (element.webkitRequestFullscreen) { // 兼容谷歌
            element.webkitRequestFullscreen();
        } else if (element.msRequestFullscreen) { // 兼容IE
            element.msRequestFullscreen();
        }
        // 切换全屏按钮
        $('#alarm-fullscreen-toggler').attr('src', '/images/close.jpg');
    } else { // 退出全屏
        console.log(document);
        $('body').removeClass('full-screen');
        $('#alarm-fullscreen-toggler').removeClass('active');
        //  退出全屏
        if (document.exitFullscreen) {
            document.exitFullscreen();
        } else if (document.mozCancelFullScreen) {
            document.mozCancelFullScreen();
        } else if (document.webkitCancelFullScreen) {
            document.webkitCancelFullScreen();
        } else if (document.msExitFullscreen) {
            document.msExitFullscreen();
        }
        // 切换全屏按钮
        $('#alarm-fullscreen-toggler').attr('src', '/images/open.jpg');
    }
});


// 滚动条设置函数
$("#App").on('scroll', function () {
    var scroH = $("#App").scrollTop();  //滚动高度
    var viewH = $(window).height();  //可见高度 
    var contentH = $(document).height();  //内容高度
    console.log("scroh:", scroH)
    if (scroH > 100) {  //距离顶部大于100px时
        console.log("scroh:", scroH)
    }
    if (contentH - (scroH + viewH) <= 100) {  //距离底部高度小于100px

    }
    if (contentH == (scroH + viewH)) {  //滚动条滑到底部啦

    }

});


$("#App").scroll(function () {
    var nDivHight = $("#div1").height();
    nScrollHight = $(this)[0].scrollHeight;
    nScrollTop = $(this)[0].scrollTop;
    if (nScrollTop + nDivHight >= nScrollHight) {
        console.log("滚动条到底部了");
    } else {

    }
})

function setScorll() {
    var chat_item = document.getElementsByClassName("chat-item");
    var itemH = $(".chat-item").outerHeight(true);
    var socrollH = chat_item.length * itemH;
    console.log(socrollH, itemH);
    $(".chat-content").scrollTop(socrollH);
}




var app = new Vue({
    el: '#App',
    data: {
        items: [
            {
                H0809: "0",
                H0910: "0",
                H1011: "0",
                H1112: "0",
                H1213: "0",
                H1314: "0",
                H1415: "0",
                H1516: "0",
                H1617: "0",
                H1718: "0",
                H1819: "0",
                H1920: "0",
                allh: "0",
                date: "20200909",
                dclass: "白班",
                id: '0',
                type: "test",
            }
        ],
        getLdData: [],
        getid: 0,
        TbobyStr: "",
        itemslength: 0,
        showRentPrise: false
    },
    methods: {
        GETDATA() {
            axios({
                method: 'get',
                url: '/getLdData',
                params: { id: this.getid, conut: 10 },

            }).then(function (resp) {
                app.items = [];
                app.items = resp.data.data
                app.itemslength = resp.data.data.length
                // console.log("resp.data:", resp);
                // console.log("items:",app.items,app.getid);
                app.getid++;
            })
                .catch(err => {
                    console.log('请求失败:' + err.status + ',' + err.statusText);
                });



        },
        domlist: function (res) {
        },


    }, mounted() {
        // window.vue = this
        let that = this
        this.GETDATA()
        window.addEventListener('scroll', () => {
            let scrollTop = document.documentElement.scrollTop ||
                document.body.scrollTop ||
                document.querySelector('#App3').scrollTop;
            //  console.log(app.$refs.text.offsetHeight)
            //  console.log(this.$refs.tr.offsetHeight)
            if (scrollTop > 55) {
                // $("#App0").hidden()
                app.showRentPrise = true
                console.log("scrollTop:", scrollTop);

            } else {
                app.showRentPrise = false
            }
        }, true);

    }, created() {
        // console.log("this.items:",this.items)
        // this.domlist()

    }
})


var getYeild = () => {
    var listData = [];
    $.ajax({
        url: '/getLdData',
        async: true,
        data: { id: this.getid, conut: 10 },
        dataType: "json",
        processData: true,
        type: "get",
        success: function (data) {
            console.log("ajax请求成功：", data)
            listData = data.data
        },
        error: (err) => {
            if (err) console.log("ajxx请求错误")
        }, complete: (res) => {
            var str = "";
            var allh = 0;
            listData.forEach((item, index, arr) => {
                str += ` 
            <td  class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.SID + `</td>
            <td  class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.date + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.type + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.dclass + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H0809 + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H0910 + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H1011 + `</td>  
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H1112 + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H1213 + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H1314 + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H1415 + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H1516 + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H1617 + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H1718 + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H1819 + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ item.H1920 + `</td>
            <td class="bg" :class="[item.dclass=='白班'?'bg-info':'bg-danger']">`+ allh + `</td>
            </tr>  `
            });
            $("#bb").html("")
            $("#bb").append(str)

        }

    });
    console.log($("tr").length)
}


var interval = 1000 * 600;
// getYeild();
const timer = setInterval(() => {
    // getYeild();
    // app.GETDATA();
}, interval);
// (getYeild,100*60)